package com.lanjiu.lib.imclient.dto.user;

import com.lanjiu.pro.business.BusinessProtocolEntities;
import com.lanjiu.lib.imclient.dto.base.Dto;

/**
 * @description: 注册用户
 * @author: Panwei
 * @date: 2019/11/14 16:14
 */
public class RegisteredUserDto extends Dto {

    // 注册用户ID
    private String userId;

    // 密码
    private String secret;

    // 注册用户昵称
    private String nickname;

    // 注册用户手机号码
    private String phone;

    // 头像
    private String avatar;

    // 验证码
    private String captcha;

    public RegisteredUserDto() {
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getCaptcha() {
        return captcha;
    }

    public void setCaptcha(String captcha) {
        this.captcha = captcha;
    }

    public RegisteredUserDto(BusinessProtocolEntities.RegisteredUser registeredUser) {
        this.userId = registeredUser.getUserId();
        this.secret = registeredUser.getSecret();
        this.nickname = registeredUser.getNickname();
        this.phone = registeredUser.getPhone();
        this.avatar = registeredUser.getAvatar();
        this.captcha = registeredUser.getCaptcha();
    }

    @Override
    public BusinessProtocolEntities.RegisteredUser toProtobuf() {
        BusinessProtocolEntities.RegisteredUser.Builder builder = BusinessProtocolEntities.RegisteredUser.newBuilder();
        if (null != userId) builder.setUserId(userId);
        if (null != secret) builder.setSecret(secret);
        if (null != nickname) builder.setNickname(nickname);
        if (null != phone) builder.setPhone(phone);
        if (null != avatar) builder.setAvatar(avatar);
        if (null != captcha) builder.setCaptcha(captcha);
        return builder.build();
    }
}
